package com.jt.sp02.service;

import com.jt.sp01.entity.Item;
import com.jt.sp01.service.ItemService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * 实现sp01的ItemService
 * @author 郭鲁政
 */
@Service
@Slf4j
public class ItemServiceImpl implements ItemService {
    @Override
    public List<Item> getItems(String orderId) {
        log.info("获取商品,orderId=\t"+orderId);
        ArrayList<Item> items = new ArrayList<>();
        items.add(new Item(1,"商品一",1));
        items.add(new Item(2,"商品二",5));
        items.add(new Item(3,"商品三",2));
        items.add(new Item(4,"商品四",3));
        items.add(new Item(5,"商品五",1));
        items.add(new Item(6,"商品六",9));
        return items;
    }

    @Override
    public void decreaseNumber(List<Item> items) {
        for (Item item : items) {
            log.info("减少库存:\t\t"+item);
        }
    }
}
